package com.spring.sunflower.userinfo;

import com.spring.sunflower.base.BaseObserver;
import com.spring.sunflower.base.BasePresenter;
import com.spring.sunflower.bean.LabelBean;
import com.spring.sunflower.bean.STSCertBean;
import com.spring.sunflower.bean.UserInfoUpdateBean;
import com.spring.sunflower.common.CommonContract;

import java.util.Map;

import io.reactivex.rxjava3.core.Observable;

/**
 * Created by Kevin on 2021/7/3<br/>
 * <p>
 * Describe:<br/>
 */
public class VoiceSignPresenter extends BasePresenter<CommonContract.VoiceSignView> {
    public VoiceSignPresenter(CommonContract.VoiceSignView baseView) {
        super(baseView);
    }

    public void getTextTemplate() {
        Observable<LabelBean> observable = requestDataSource.requestLabel("voiceSignatureTxtInfo");
        addDisposable(observable, new BaseObserver<LabelBean>(baseView) {

            @Override
            public void onSuccess(LabelBean bean) {
                baseView.hideLoading();
                baseView.showTextTemplate(bean.getDatas());
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }
    public void updateUserInfo(Map<String, String> map) {
        Observable<UserInfoUpdateBean> observable = requestDataSource.userInfoUpdate(map);
        addDisposable(observable, new BaseObserver<UserInfoUpdateBean>(baseView) {

            @Override
            public void onSuccess(UserInfoUpdateBean bean) {
                baseView.updateSuccess(bean.getDatas());
            }

            @Override
            public void onError(int status, String msg) {
                baseView.updateFailed();
            }
        });
    }
    public void getSTSCert() {
        Observable<STSCertBean> observable = requestDataSource.getSTSCert();
        addDisposable(observable, new BaseObserver<STSCertBean>(baseView) {

            @Override
            public void onSuccess(STSCertBean bean) {
                STSCertBean.DatasBean datas = bean.getDatas();
                baseView.loadSTSCert(datas);
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }
}
